//
//  DRTabBarController.m
//  DoctorRen
//
//  Created by Lemon on 2018/11/19.
//

#import "DRTabBarController.h"
#import "DRDragImageView.h"

@interface DRTabBarController ()

@property (nonatomic, strong) DRDragImageView *kefu;

@end

@implementation DRTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.tabBar.tintColor = There_Green;
    NSArray *image = @[@"底栏_健康食话", @"底栏_智能配餐", @"底栏_食疗管理", @"底栏_健康煮艺", @"底栏_我的"];
    NSArray *items = self.tabBar.items;
//    self.tabBar.shadowImage = [UIImage new];
    self.tabBar.backgroundImage = [UIImage new];
    for (int i = 0; i < image.count; i++) {
        [self p_setItem:items[i] image:image[i]];
    }
    [self.kefu setHidden:NO];
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapKeFu)];
    [self.kefu addGestureRecognizer:tap];
}

-(DRDragImageView *)kefu{
    if (!_kefu) {
        DRDragImageView *iv = [[DRDragImageView alloc] initWithFrame:(CGRectMake(SCREEN_WIDTH - 50, SCREEN_HEIGHT - 150, 50, 50))];
        iv.backgroundColor = [UIColor whiteColor];
        iv.layer.cornerRadius = 25;
        iv.image = [UIImage imageNamed:@"kefu"];
        [self.view insertSubview:iv atIndex:9999];
        _kefu = iv;
    }
    return _kefu;
}

- (void)p_setItem:(UITabBarItem *)item image:(NSString *)image  {
    item.image = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_0",image]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    item.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_1",image]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}



-(void)setKfButtonIsHidden:(BOOL)kfButtonIsHidden{
    _kfButtonIsHidden = kfButtonIsHidden;
    [self.kefu setHidden:kfButtonIsHidden];

}

-(void)tapKeFu{
    if([DRLoginDataModel getUserToken].length == 0){
        [self presentNeedLogin:NO];
        return;
    }
    UINavigationController *vc = self.selectedViewController;
    [vc.topViewController pushWebViewWithUrl:[NSString stringWithFormat:@"http://rsjkkj.com/dist/#/CustomerService?isBack=1&token=%@",[DRLoginDataModel getUserToken]]];
}

@end
